import numpy as np
from scipy import linalg as sp
import tables as tb
from xml.etree.ElementTree import parse
from collections import namedtuple
import math
import matplotlib.pyplot as plt
from Brayn import BraynAlg

class MaxEnt:  
    def singleRun(self, alpha):
        runData = self.bAlg.minimizeA(alpha)
        return runData
    def run(self, simData, mxData):
        self.bAlg = BraynAlg(simData, mxData)
        self.mxData = mxData    
        alphasSA = np.flipud(np.logspace(self.mxData.alphaMax, self.mxData.alphaHigh, self.mxData.numAlpha))  
        alphas = np.flipud(np.logspace(self.mxData.alphaMin, self.mxData.alphaMax, self.mxData.numAlpha))
        runsData = []
        for alpha in alphasSA:
            self.singleRun(alpha)
            print "alpha", alpha        
        print "Finished SA"
        for alpha in alphas:
            rData = self.singleRun(alpha)
            runsData.append(rData)
            print "alpha", alpha
        return runsData, self.mxData
        

            
            
            
